// 调用同名的方法

trait Pilot {
    fn fly(&self);
}

trait Wizard {
    fn fly(&self);
}

struct Human;

impl Pilot for Human {
    fn fly(&self){
        println!("This is your captain speaking");
    }
}

impl Wizard for Human {
    fn fly(&self) {
        println!("Up!");
    }
}

impl Human {
    fn fly(&self) {
        println!("*waving arms furiously*");
    }
}
//完全限定调用特征上方法
trait Animal {
    fn baby_name() -> String;
}
struct Dog;
impl Dog {
    fn baby_name() -> String {
        "Spot".to_string()
    }
}
impl Animal for Dog {
    fn baby_name() -> String {
        "puppy".to_string()
    }
}
fn main() {
    let person = Human;
    person.fly(); // 优先调用类型上方法
    Human::fly(&person);
    Pilot::fly(&person); // 调用特征上方法
    Wizard::fly(&person); // 调用特征上方法
    //完全限定调用特征上方法
    println!("A baby dog is called a {}", Dog::baby_name());
    println!("A baby dog with animal is called a {}", <Dog as Animal>::baby_name());
}
